home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / FileTransfers.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  15KB  |  384 lines

  1. /*
  2.      File:        FileTransfers.h
  3.  
  4.      Contains:    CommToolbox File Transfer Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __FILETRANSFERS__
  19. #define __FILETRANSFERS__
  20.  
  21. #ifndef __WINDOWS__
  22. #include <Windows.h>
  23. #endif
  24. #ifndef __STANDARDFILE__
  25. #include <StandardFile.h>
  26. #endif
  27. #ifndef __CTBUTILITIES__
  28. #include <CTBUtilities.h>
  29. #endif
  30. #ifndef __CONNECTIONS__
  31. #include <Connections.h>
  32. #endif
  33. #ifndef __FILES__
  34. #include <Files.h>
  35. #endif
  36. #ifndef __TERMINALS__
  37. #include <Terminals.h>
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_ALIGN_SUPPORTED
  49. #pragma options align=mac68k
  50. #endif
  51.  
  52. #if FOR_SYSTEM7_ONLY
  53.  
  54. enum {
  55.                                                                 /* current file transfer manager version    */
  56.     curFTVersion                = 2,                            /* FTErr    */
  57.     ftGenericError                = -1,
  58.     ftNoErr                        = 0,
  59.     ftRejected                    = 1,
  60.     ftFailed                    = 2,
  61.     ftTimeOut                    = 3,
  62.     ftTooManyRetry                = 4,
  63.     ftNotEnoughDSpace            = 5,
  64.     ftRemoteCancel                = 6,
  65.     ftWrongFormat                = 7,
  66.     ftNoTools                    = 8,
  67.     ftUserCancel                = 9,
  68.     ftNotSupported                = 10
  69. };
  70.  
  71. typedef OSErr FTErr;
  72.  
  73. enum {
  74.     ftIsFTMode                    = 1 << 0,
  75.     ftNoMenus                    = 1 << 1,
  76.     ftQuiet                        = 1 << 2,
  77.     ftConfigChanged                = 1 << 4,
  78.     ftSucc                        = 1 << 7
  79. };
  80.  
  81. typedef unsigned long FTFlags;
  82.  
  83. enum {
  84.     ftSameCircuit                = 1 << 0,
  85.     ftSendDisable                = 1 << 1,
  86.     ftReceiveDisable            = 1 << 2,
  87.     ftTextOnly                    = 1 << 3,
  88.     ftNoStdFile                    = 1 << 4,
  89.     ftMultipleFileSend            = 1 << 5
  90. };
  91.  
  92. typedef unsigned short FTAttributes;
  93.  
  94. enum {
  95.     ftReceiving                    = 0,
  96.     ftTransmitting                = 1
  97. };
  98.  
  99. typedef unsigned short FTDirection;
  100. typedef pascal long (*FileTransferDefProcPtr)(TermHandle hTerm, short msg, long p1, long p2, long p3);
  101. /*    application routines type definitions */
  102. typedef struct FTRecord FTRecord;
  103. typedef FTRecord *FTPtr;
  104. typedef FTPtr *FTHandle;
  105. typedef pascal OSErr (*FileTransferReadProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  106. typedef pascal OSErr (*FileTransferWriteProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  107. typedef pascal Size (*FileTransferSendProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags flag);
  108. typedef pascal Size (*FileTransferReceiveProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags *flag);
  109. typedef pascal OSErr (*FileTransferEnvironsProcPtr)(long refCon, ConnEnvironRec *theEnvirons);
  110. typedef pascal void (*FileTransferNotificationProcPtr)(FTHandle hFT, FSSpecPtr pFSSpec);
  111. typedef pascal void (*FileTransferChooseIdleProcPtr)(void );
  112.  
  113. #if GENERATINGCFM
  114. typedef UniversalProcPtr FileTransferDefUPP;
  115. typedef UniversalProcPtr FileTransferReadUPP;
  116. typedef UniversalProcPtr FileTransferWriteUPP;
  117. typedef UniversalProcPtr FileTransferSendUPP;
  118. typedef UniversalProcPtr FileTransferReceiveUPP;
  119. typedef UniversalProcPtr FileTransferEnvironsUPP;
  120. typedef UniversalProcPtr FileTransferNotificationUPP;
  121. typedef UniversalProcPtr FileTransferChooseIdleUPP;
  122. #else
  123. typedef FileTransferDefProcPtr FileTransferDefUPP;
  124. typedef FileTransferReadProcPtr FileTransferReadUPP;
  125. typedef FileTransferWriteProcPtr FileTransferWriteUPP;
  126. typedef FileTransferSendProcPtr FileTransferSendUPP;
  127. typedef FileTransferReceiveProcPtr FileTransferReceiveUPP;
  128. typedef FileTransferEnvironsProcPtr FileTransferEnvironsUPP;
  129. typedef FileTransferNotificationProcPtr FileTransferNotificationUPP;
  130. typedef FileTransferChooseIdleProcPtr FileTransferChooseIdleUPP;
  131. #endif
  132. struct FTRecord {
  133.     short                             procID;
  134.     FTFlags                         flags;
  135.     FTErr                             errCode;
  136.     long                             refCon;
  137.     long                             userData;
  138.     FileTransferDefUPP                 defProc;
  139.     Ptr                             config;
  140.     Ptr                             oldConfig;
  141.     FileTransferEnvironsUPP         environsProc;
  142.     long                             reserved1;
  143.     long                             reserved2;
  144.     Ptr                             ftPrivate;
  145.     FileTransferSendUPP             sendProc;
  146.     FileTransferReceiveUPP             recvProc;
  147.     FileTransferWriteUPP             writeProc;
  148.     FileTransferReadUPP             readProc;
  149.     WindowPtr                         owner;
  150.     FTDirection                     direction;
  151.     SFReply                         theReply;
  152.     long                             writePtr;
  153.     long                             readPtr;
  154.     Ptr                             theBuf;
  155.     long                             bufSize;
  156.     Str255                             autoRec;
  157.     FTAttributes                     attributes;
  158. };
  159.  
  160.  
  161. enum {
  162.                                                                 /* FTReadProc messages */
  163.     ftReadOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  164.     ftReadDataFork                = 1,
  165.     ftReadRsrcFork                = 2,
  166.     ftReadAbort                    = 3,
  167.     ftReadComplete                = 4,
  168.     ftReadSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  169.     ftReadGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  170.                                                                 /* FTWriteProc messages */
  171.     ftWriteOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  172.     ftWriteDataFork                = 1,
  173.     ftWriteRsrcFork                = 2,
  174.     ftWriteAbort                = 3,
  175.     ftWriteComplete                = 4,
  176.     ftWriteFileInfo                = 5,
  177.     ftWriteSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  178.     ftWriteGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  179.                                                                 /*    fork flags */
  180.     ftOpenDataFork                = 1,
  181.     ftOpenRsrcFork                = 2
  182. };
  183.  
  184.  
  185. enum {
  186.     uppFileTransferDefProcInfo = kPascalStackBased
  187.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  188.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  189.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  190.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  191.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  192.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  193.     uppFileTransferReadProcInfo = kPascalStackBased
  194.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  195.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long *)))
  196.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  197.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  198.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  199.     uppFileTransferWriteProcInfo = kPascalStackBased
  200.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  201.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long *)))
  202.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  203.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  204.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  205.     uppFileTransferSendProcInfo = kPascalStackBased
  206.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  207.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  208.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  209.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  210.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  211.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags))),
  212.     uppFileTransferReceiveProcInfo = kPascalStackBased
  213.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  214.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  215.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  216.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  217.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  218.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags *))),
  219.     uppFileTransferEnvironsProcInfo = kPascalStackBased
  220.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  221.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  222.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ConnEnvironRec *))),
  223.     uppFileTransferNotificationProcInfo = kPascalStackBased
  224.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FTHandle)))
  225.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FSSpecPtr))),
  226.     uppFileTransferChooseIdleProcInfo = kPascalStackBased
  227. };
  228.  
  229. #if GENERATINGCFM
  230. #define NewFileTransferDefProc(userRoutine)        \
  231.         (FileTransferDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferDefProcInfo, GetCurrentArchitecture())
  232. #define NewFileTransferReadProc(userRoutine)        \
  233.         (FileTransferReadUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReadProcInfo, GetCurrentArchitecture())
  234. #define NewFileTransferWriteProc(userRoutine)        \
  235.         (FileTransferWriteUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferWriteProcInfo, GetCurrentArchitecture())
  236. #define NewFileTransferSendProc(userRoutine)        \
  237.         (FileTransferSendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferSendProcInfo, GetCurrentArchitecture())
  238. #define NewFileTransferReceiveProc(userRoutine)        \
  239.         (FileTransferReceiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, GetCurrentArchitecture())
  240. #define NewFileTransferEnvironsProc(userRoutine)        \
  241.         (FileTransferEnvironsUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, GetCurrentArchitecture())
  242. #define NewFileTransferNotificationProc(userRoutine)        \
  243.         (FileTransferNotificationUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, GetCurrentArchitecture())
  244. #define NewFileTransferChooseIdleProc(userRoutine)        \
  245.         (FileTransferChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo, GetCurrentArchitecture())
  246. #else
  247. #define NewFileTransferDefProc(userRoutine)        \
  248.         ((FileTransferDefUPP) (userRoutine))
  249. #define NewFileTransferReadProc(userRoutine)        \
  250.         ((FileTransferReadUPP) (userRoutine))
  251. #define NewFileTransferWriteProc(userRoutine)        \
  252.         ((FileTransferWriteUPP) (userRoutine))
  253. #define NewFileTransferSendProc(userRoutine)        \
  254.         ((FileTransferSendUPP) (userRoutine))
  255. #define NewFileTransferReceiveProc(userRoutine)        \
  256.         ((FileTransferReceiveUPP) (userRoutine))
  257. #define NewFileTransferEnvironsProc(userRoutine)        \
  258.         ((FileTransferEnvironsUPP) (userRoutine))
  259. #define NewFileTransferNotificationProc(userRoutine)        \
  260.         ((FileTransferNotificationUPP) (userRoutine))
  261. #define NewFileTransferChooseIdleProc(userRoutine)        \
  262.         ((FileTransferChooseIdleUPP) (userRoutine))
  263. #endif
  264.  
  265. #if GENERATINGCFM
  266. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  267.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferDefProcInfo, (hTerm), (msg), (p1), (p2), (p3))
  268. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  269.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReadProcInfo, (count), (pData), (refCon), (fileMsg))
  270. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  271.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferWriteProcInfo, (count), (pData), (refCon), (fileMsg))
  272. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  273.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferSendProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  274. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  275.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  276. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  277.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, (refCon), (theEnvirons))
  278. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  279.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, (hFT), (pFSSpec))
  280. #define CallFileTransferChooseIdleProc(userRoutine)        \
  281.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo)
  282. #else
  283. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  284.         (*(userRoutine))((hTerm), (msg), (p1), (p2), (p3))
  285. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  286.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  287. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  288.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  289. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  290.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  291. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  292.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  293. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  294.         (*(userRoutine))((refCon), (theEnvirons))
  295. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  296.         (*(userRoutine))((hFT), (pFSSpec))
  297. #define CallFileTransferChooseIdleProc(userRoutine)        \
  298.         (*(userRoutine))()
  299. #endif
  300. extern pascal FTErr InitFT(void );
  301.  
  302. extern pascal Handle FTGetVersion(FTHandle hFT);
  303.  
  304. extern pascal short FTGetFTVersion(void );
  305.  
  306. extern pascal FTHandle FTNew(short procID, FTFlags flags, FileTransferSendUPP sendProc, FileTransferReceiveUPP recvProc, FileTransferReadUPP readProc, FileTransferWriteUPP writeProc, FileTransferEnvironsUPP environsProc, WindowPtr owner, long refCon, long userData);
  307.  
  308. extern pascal void FTDispose(FTHandle hFT);
  309.  
  310. extern pascal FTErr FTStart(FTHandle hFT, FTDirection direction, const SFReply *fileInfo);
  311.  
  312. extern pascal FTErr FTAbort(FTHandle hFT);
  313.  
  314. extern pascal FTErr FTSend(FTHandle hFT, short numFiles, FSSpecArrayPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  315.  
  316. extern pascal FTErr FTReceive(FTHandle hFT, FSSpecPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  317.  
  318. extern pascal void FTExec(FTHandle hFT);
  319.  
  320. extern pascal void FTActivate(FTHandle hFT, Boolean activate);
  321.  
  322. extern pascal void FTResume(FTHandle hFT, Boolean resume);
  323.  
  324. extern pascal Boolean FTMenu(FTHandle hFT, short menuID, short item);
  325.  
  326. extern pascal short FTChoose(FTHandle *hFT, Point where, FileTransferChooseIdleUPP idleProc);
  327.  
  328. extern pascal void FTEvent(FTHandle hFT, const EventRecord *theEvent);
  329.  
  330. extern pascal Boolean FTValidate(FTHandle hFT);
  331.  
  332. extern pascal void FTDefault(Ptr *theConfig, short procID, Boolean allocate);
  333.  
  334. extern pascal Handle FTSetupPreflight(short procID, long *magicCookie);
  335.  
  336. extern pascal void FTSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  337.  
  338. extern pascal Boolean FTSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  339.  
  340. extern pascal void FTSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  341.  
  342. extern pascal void FTSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  343.  
  344. extern pascal void FTSetupPostflight(short procID);
  345.  
  346. extern pascal Ptr FTGetConfig(FTHandle hFT);
  347.  
  348. extern pascal short FTSetConfig(FTHandle hFT, const void *thePtr);
  349.  
  350. extern pascal OSErr FTIntlToEnglish(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  351.  
  352. extern pascal OSErr FTEnglishToIntl(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  353.  
  354. extern pascal void FTGetToolName(short procID, Str255 name);
  355.  
  356. extern pascal short FTGetProcID(ConstStr255Param name);
  357.  
  358. extern pascal void FTSetRefCon(FTHandle hFT, long refCon);
  359.  
  360. extern pascal long FTGetRefCon(FTHandle hFT);
  361.  
  362. extern pascal void FTSetUserData(FTHandle hFT, long userData);
  363.  
  364. extern pascal long FTGetUserData(FTHandle hFT);
  365.  
  366. extern pascal void FTGetErrorString(FTHandle hFT, short id, Str255 errMsg);
  367.  
  368. #endif
  369.  
  370. #if PRAGMA_ALIGN_SUPPORTED
  371. #pragma options align=reset
  372. #endif
  373.  
  374. #if PRAGMA_IMPORT_SUPPORTED
  375. #pragma import off
  376. #endif
  377.  
  378. #ifdef __cplusplus
  379. }
  380. #endif
  381.  
  382. #endif /* __FILETRANSFERS__ */
  383.  
  384.